package com.mark.base.service;

import com.mark.base.dao.LabelDao;
import com.mark.base.pojo.Label;
import com.mark.util.IdWorker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author Markburt
 * @Description :
 * @DATE: 6/8/2020
 * @TIME: 1:38 PM
 * @YEAR: 2020
 * @Version :
 **/
@Service
@Transactional
@SuppressWarnings("all")
public class LabelService {

    /***
     * 注意 这里将 @Autowired(Spring) 改为 @Resource(JDK)
     */
    @Resource
    private final LabelDao labelDao;

    @Resource
    private final IdWorker idWorker;

    /**
     * 构造器注入
     *
     * @param labelDao
     * @param idWorker
     */
    @Autowired
    public LabelService(LabelDao labelDao, IdWorker idWorker) {
        this.idWorker = idWorker;
        this.labelDao = labelDao;
    }

    /***
     * 保存
     * @param label
     */
    public void save(Label label) {
        label.setId(idWorker.nextId() + "");
        labelDao.save(label);
    }

    /***
     * 查找所有
     * @return
     */
    public List<Label> findAll() {
        return labelDao.findAll();
    }









































}
